* Clean up
clear all

/* Set working directory: please set your own
cd "~/Dropbox/JOP third submission/JOP replication/"
*/

* Open dataset
use 01_data/elections_ciutadella.dta, clear

* No fixed effects
regr pp_voteshare ep if year == 2019, cluster(table_code_notelectionspecific)
est store cross_section1
estadd local  FE "No"

* With voting station fixed effects
regr pp_voteshare ep i.table_code_notelectionspecific if year == 2019, cluster(table_code_notelectionspecific)
est store cross_section2
estadd local  FE "Yes"

* With dummies for each election type
regr pp_voteshare ep municipal autonomic if year == 2019, cluster(table_code_notelectionspecific)
est store cross_section3
estadd local  FE "No"

* With dummies for each election type and voting station fixed effects
regr pp_voteshare ep municipal autonomic i.table_code_notelectionspecific if year == 2019, cluster(table_code_notelectionspecific)
est store cross_section4
estadd local  FE "Yes"

* Make table
esttab cross_section1 cross_section2 cross_section3 cross_section4 using 03_tables/tabled10.tex, tex se replace nomtitles keep(ep municipal autonomic _cons) coeflabels (ep "European election" municipal "Municipal election" autonomic "Autonomic election" _cons "Constant") s(FE, label("Voting station fixed effects")) star(* 0.10 ** 0.05 *** 0.01) addnotes("Standard errors are clustered by voting station" "In models 3 and 4, the reference category are Elections for the Balearic Council.") scalars(e(N))
